package 比较器;

import java.util.ArrayList;
import java.util.List;

public class T1 {

    public static void main(String[] args) {

        List<Dog> list = new ArrayList<>();
        list.add(new Dog("哈士奇", 1, 3));
        list.add(new Dog("藏獒", 2, 12));
        list.add(new Dog("博美", 2, 6));
        list.add(new Dog("柴犬", 3, 12));

        System.out.println("排序前：" + list);

        list.sort((o1, o2) -> {
            int i = o2.getAge() - o1.getAge();
            return i == 0 ? o2.getWeight() - o1.getWeight() : i;
        });

        System.out.println("排序后："+list);

    }
}
